<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="d" uri="http://dgg.net/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>证书信息列表</title>
    <%@ include file="../../../header.jsp" %>
    <style type="text/css">
        .layui-layer-content{
            max-height: 662px;
            margin: 10px;
        }
    </style>
</head>
<body class="body-main">
<div class="titleSearch">
    <form id="titleSearch">
        <d:hasUrlAuth authCode="ZZSC_ZS_SYB">
            <div class="layui-inline">
                <label>所属事业部：</label>
                <div class="layui-input-inline">
                    <select name="signOrgId" id="signOrgId" class="input-style" autocomplete="off">
                        <option value="">全部</option>
                    </select>
                </div>
            </div>
        </d:hasUrlAuth>

        <div class="layui-inline">
            <label>证书类型：</label>
            <div class="layui-input-inline">
                <select class="select-style" name="certificateType" id="certificateType1"
                        onchange="loadCertificateType('190px','#certificateType1','${generalType}',1,'#certificateSpecialtys1',0,'#certificateLevel1')">
                    <option value="">请选择</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label>证书专业：</label>
            <div class="layui-input-inline">
                <select class="select-style" name="certificateSpecialtys" id="certificateSpecialtys1" onchange="checkCertificateSpecialty('#certificateType1','#certificateSpecialtys1')" style="width:150px">
                    <option value="">请先选择证书类型</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label>证书等级：</label>
            <div class="layui-input-inline">
                <select class="select-style" name="certificateLevel" id="certificateLevel1" style="width:150px">
                    <option value="">请先选择证书类型</option>
                </select>
            </div>
        </div>

        <div class="layui-inline">
            <label>超期状态：</label>
            <div class="layui-input-inline">
                <select class="select-style" id="overdueStatus" name="overdueStatus">
                    <option value="">全部</option>
                    <option value="0" <c:if test="${!empty overdueStatu && overdueStatu == 0}">selected</c:if>>超期</option>
                    <option value="1" <c:if test="${!empty overdueStatu && overdueStatu == 1}">selected</c:if>>未超期</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label>超期类型：</label>
            <div class="layui-input-inline">
                <select class="select-style" id="overdueType" name="overdueType">
                    <option value="">全部</option>
                    <c:forEach var="p" items="${overDueType}">
                        <option value="${p.code}" <c:if test="${!empty overdueTypes && overdueTypes == p.code}">selected</c:if>>${p.name}</option>
                    </c:forEach>
                </select>
            </div>
        </div>

        <div class="layui-inline">
            <label>在库类型：</label>
            <div class="layui-input-inline">
                <select class="select-style" name="libraryStatus">
                    <option value="">全部</option>
                    <c:forEach var="p" items="${libraryStatus}">
                        <option value="${p.code}" <c:if test="${!empty libraryStatu && libraryStatu == p.code}">selected</c:if>>${p.name}</option>
                    </c:forEach>
                </select>
            </div>
        </div>

        <div class="layui-inline">
            <label>入库时间：</label>
            <div class="layui-inline">
                <input style="width: 120px" type="text" name="lastWarehousingStartTime" placeholder="开始时间" class="Wdate input-style" id="lastWarehousingStartTime"
                       onfocus="var endDate=$dp.$('lastWarehousingEndTime'); WdatePicker({onpicked:function(){endDate.focus();}, maxDate:'#F{ $dp.$D(\'lastWarehousingEndTime\')}', dateFmt:'yyyy-MM-dd'})">
            </div>
            <span>-</span>
            <div class="layui-inline">
                <input style="width: 120px"  type="text" name="lastWarehousingEndTime" placeholder="结束时间" class="Wdate input-style" id="lastWarehousingEndTime"
                       onfocus="WdatePicker({minDate:'#F{$dp.$D(\'lastWarehousingStartTime\')}', dateFmt:'yyyy-MM-dd'})">
            </div>
        </div>

        <div class="layui-inline">
            <label>创建时间：</label>
            <div class="layui-inline">
                <input style="width: 120px" type="text" name="createStartTime" placeholder="开始时间" class="Wdate input-style" id="createStartTime"
                       onfocus="var endDate=$dp.$('createEndTime'); WdatePicker({onpicked:function(){endDate.focus();}, maxDate:'#F{ $dp.$D(\'createEndTime\')}', dateFmt:'yyyy-MM-dd'})">
            </div>
            <span>-</span>
            <div class="layui-inline">
                <input style="width: 120px"  type="text" name="createEndTime" placeholder="结束时间" class="Wdate input-style" id="createEndTime"
                       onfocus="WdatePicker({minDate:'#F{$dp.$D(\'createStartTime\')}', dateFmt:'yyyy-MM-dd'})">
            </div>
        </div>

        <div class="layui-inline">
            <label>地区：</label>
            <div class="layui-input-inline">
                <div class="bus-plugIn" id="certificateArea">
                    <input type="hidden" name="certificateAreaId" class="plug-in-msg"/>
                    <input type="hidden" name="certificateArea" class="plug-in-code"/>
                    <input type="text" readonly placeholder="请选择" class="chose-plugIn layui-input" id="certificateAreaChange" name="areaName1">
                    <div class="bus-picker">
                        <div class="bus-picker-tab">
                            <a href="javascript:void(0);" class="active">请选择</a>
                        </div>
                        <div class="bus-picker-content"></div>
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-inline">
            <label>适用范围：</label>
            <div class="layui-input-inline">
                <select class="select-style" name="applicationScopes">
                    <option value="">全部</option>
                    <c:forEach var="p" items="${applicationScopes}">
                        <option value="${p.code}" <c:if test="${!empty scope && scope == p.code}">selected</c:if>>${p.name}</option>
                    </c:forEach>
                </select>
            </div>
        </div>

        <div class="layui-inline">
            <label>是否购买社保：</label>
            <div class="layui-input-inline">
                <select class="select-style" name="socialSecurity1">
                    <option value="">请选择</option>
                    <c:forEach var="p" items="${socialSecurity}">
                        <option value="${p.code}" <c:if test="${!empty scope && scope == p.code}">selected</c:if>>${p.name}</option>
                    </c:forEach>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label>社保区域：</label>
            <div class="layui-input-inline">
                <div class="bus-plugIn" id="socialSecurityArea">
                    <input type="hidden" name="socialSecurityAreaId" class="plug-in-msg"/>
                    <input type="hidden" name="socialSecurityArea" class="plug-in-code"/>
                    <input type="text" readonly placeholder="请选择" class="chose-plugIn layui-input" id="socialSecurityAreaChange" name="socialSecurityAreaChange1">
                    <div class="bus-picker">
                        <div class="bus-picker-tab">
                            <a href="javascript:void(0);" class="active">请选择</a>
                        </div>
                        <div class="bus-picker-content"></div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-inline">
            <label>收证类型：</label>
            <div class="layui-input-inline">
                <select class="select-style" name="receiptType1">
                    <option value="">全部</option>
                    <option value="0">渠道收证</option>
                    <option value="1">人才收证</option>
                </select>
            </div>
        </div>

        <div class="layui-inline">
            <label>证书状态：</label>
            <div class="layui-input-inline">
                <select class="select-style" name="generalCredentialStatus">
                    <option value="">全部</option>
                    <c:forEach var="p" items="${generalCredentialStatus}">
                        <option value="${p.code}" <c:if test="${!empty generalCredentialStatu && generalCredentialStatu == p.code}">selected</c:if>>${p.name}</option>
                    </c:forEach>
                </select>
            </div>
        </div>

        <div class="layui-inline">
            <label>持证人电话：</label>
            <div class="layui-input-inline">
                <input type="text" class="input-style win100" id="personalPhone1" name="personalPhone"/>
            </div>
        </div>
        <div class="layui-inline">
            <label>身份证号码：</label>
            <div class="layui-input-inline">
                <input type="text" class="input-style win250" id="personalIdCard" name="personalIdCard"/>
            </div>
        </div>
        <div class="layui-inline">
            <label>关键字：</label>
            <div class="layui-input-inline">
                <input type="text" class="input-style win250" placeholder="持证人/收证商务/证书编号/证书名称" id="keywords" name="keywords" value="${keywords}"/>
            </div>
        </div>
        <input type="hidden" name="createTime" value="${createTime}">
    </form>
    <div class="layui-inline">
        <d:hasUrlAuth authCode="ZZSC_ADMIN_EDIT">
            <input type="hidden" name="adminEdit" value="1">
        </d:hasUrlAuth>
        <button class="layui-btn layui-btn-mini layui-btn-normal" onclick="search('#myTable','reload')">搜索</button>
        <button class="layui-btn layui-btn-mini layui-btn-primary" onclick="cleanSearchWithHidden()">清空</button>
    </div>
</div>
<div class="table-conter">

    <d:hasUrlAuth authCode="ZZSC_ZS_PLZKZSZT">
        <a href="javascript:void(0)" class="layui-btn layui-btn-mini" onclick="updateCertificateStatus()">批量在库/证书状态</a>
    </d:hasUrlAuth>
    <d:hasUrlAuth authCode="ZZSC_ZS_OPERATION">
        <d:hasUrlAuth authCode="ZZSC_ZS_DC">
        <a href="javascript:void(0)" class="layui-btn layui-btn-mini" onclick="exportInfo()">导出</a>
        </d:hasUrlAuth>
        <d:hasUrlAuth authCode="ZZSC_ZS_QBDC">
            <a href="javascript:void(0)" class="layui-btn layui-btn-mini" onclick="exportAllInfo()">全部导出</a>
        </d:hasUrlAuth>
        <d:hasUrlAuth authCode="ZZSC_ZS_SYZS">
        <a href="javascript:void(0)" class="layui-btn layui-btn-mini" onclick="affiliatedCredential()">使用证书</a>
        </d:hasUrlAuth>
        <d:hasUrlAuth authCode="ZZSC_ZS_QXXYZT">
        <a href="javascript:void(0)" class="layui-btn layui-btn-mini" onclick="cancelStatus()">取消现有状态</a>
        </d:hasUrlAuth>
        <d:hasUrlAuth authCode="ZZSC_ZS_QXXYZT">
        <a href="javascript:void(0)" class="layui-btn layui-btn-mini" onclick="businessRenewal()">企业续签</a>
        </d:hasUrlAuth>
        <input type="hidden" name="hasOperation" value = "0">
    </d:hasUrlAuth>
</div>

<table id="myTable" class="cell-border crm-table">
</table>
<%@ include file="../../../footer.jsp" %>

<script src="${rootUrl}/static/js/zzsc/credential/credentailCommon/credentailCommon.js?v=${version}"></script>
<script src="${rootUrl}/static/js/zzsc/credential/generalCertificate/editGeneralCertificate.js?v=${version}"></script>
<script src="${rootUrl}/static/js/zzsc/credential/generalCertificate/generalCertificateInfo.js?v=${version}"></script>
<script src="${rootUrl}/static/js/zzsc/production/sc_common.js?v=${version}"></script>
<script src="${rootUrl}/static/js/zzsc/common/sc_chooseUser.js?v=${version}" type="text/javascript" charset="utf-8"></script>
<script>
    $(function () {
        $('#myTable').dataTableExtend({
            "ajax": {
                "url": "${rootUrl}/zs/general_credential/general_certificate_info_data.do",
                "type": "post"
            }, "fnServerParams": function (aoData) {
                var checkResult = checkHasSybAuth($('#signOrgId option'));
                if (!checkResult) {
                    aoData = $.extend(aoData, {"isAll": "0"});
                }
                aoData = $.extend(aoData, $('.titleSearch').serialize2object());
                return aoData;
            },
            "pageLength": 20,//每页显示的条数默认是10条，有特殊业务需要显示不同条数的列表才应该加入该参数
            "scrollX": true,//是否开启横项滚动
            "fixedColumns": {//锁定列，只有开启scrollX时才生效
                "leftColumns": 3,//左侧锁定2列
                "rightColumns": 1//右侧锁定1列
            },
            "aoColumns": [
                {
                    "title": '<input type="checkbox" class="checkall"/>',
                    "sClass": "check-th",
                    "orderable": false,
                    "data": "productId",
                    "render": function (data, type, full, meta) {
                        return '<input type="checkbox"  class="checkchild"  value="' + data + '" />';
                    }
                },
                {
                    "title": "序号",
                    "orderable": false,
                    "render": function (data, type, full, meta) {
                        return meta.row + 1;
                    }
                },
                {
                    "title": "所属事业部",
                    "data": "signOrgName",
                    "orderable": false
                },
                {
                    "title": "配证生产订单编号",
                    "data": "scOrderNo",
                    "orderable": false,
                    "render": function (data, type, row, meta) {
                        return checkIsEmpty(data) ? '-' : "<a href='javascript:void(0);'  class='layui-table-link' onclick='openOrderInfoDetail(\"" + data + "\",\"" + row.scOrderId + "\")'>" + data + "</a>";
                    }
                },
                {
                    "title": "收证商务",
                    "data": "collectorName",
                    "orderable": false,
                },
                {
                    "title": "证书名称/编号",
                    "data": "certificateName",
                    "orderable": false,
                    "render": function (data, type, row, meta) {
                        return data + "<br/><a href='javascript:void(0);'  class='layui-table-link' onclick='credentialDetail(\"" + row.certificateNo + "\",\"" + row.id + "\")'>" + row.certificateNo + "</a>";
                    }
                },
                {
                    "title": "持证人/身份证",
                    "data": "personalName",
                    "orderable": false,
                    "render": function (data, type, row, meta) {
                        var idCard = (null != row.personalIdCard && "" != row.personalIdCard) ? hideStr(row.personalIdCard, 1, row.personalIdCard.length - 16) : "";
                        return "<span>" + data + "</span><br/>" + idCard;
                    }
                },
                {
                    "title": "类型/专业/等级",
                    "data": "certificateType",
                    "orderable": false,
                    "render": function (data, type, row, meta) {
                        data = (null != data && "" != data) ? data : "-";
                        var certificateSpecialtys = (null != row.certificateSpecialtys && "" != row.certificateSpecialtys) ? row.certificateSpecialtys : "-";
                        return data + "<br/><div title='" + certificateSpecialtys + "' class='f-toe' style=\"max-width:100px;word-wrap:break-word\">" + certificateSpecialtys + "</div>" + row.certificateLevel;
                    }
                },
                {
                    "title": "类别",
                    "data": "certificateCategory",
                    "orderable": false,
                    "render": function (data, type, row, meta) {
                        return !checkIsEmpty(data) ? data : "-";
                    }
                },
                {
                    "title": "收证价格(元)",
                    "data": "receiptPrice",
                    "orderable": false, "render": function (data, type, row, meta) {
                        return fmtMoney(data);
                    }
                },
                {
                    "title": "打款金额(元)",
                    "data": "accountMoney",
                    "orderable": false,
                    "render": function (data, type, row, meta) {
                        return fmtMoney(data);
                    }
                },
                {
                    "title": "总价(元)",
                    "data": "certificatePrice",
                    "orderable": false,
                    "render": function (data, type, row, meta) {
                        return fmtMoney(data);
                    }
                },
                {
                    "title": "在库/证书状态",
                    "data": "certificateStatus",
                    "orderable": false,
                    "render": function (data, type, row, meta) {
                        return row.libraryStatus + "<br/>" + data;
                    }
                },
                {
                    "title": "超期状态",
                    "data": "overdueStatus",
                    "orderable": false,
                    "render": function (data, type, row, meta) {
                        var overdueTypes = !checkIsEmpty(data) && data === "0" ? "<span style='color:red'>超期</span><br/>" : "<span  style='color:green'>未超期</span><br/>";
                        if (!checkIsEmpty(row.overdueType) && row.overdueStatus === "0") { // 超期
                            if (!checkIsEmpty(row.overdueType)) {
                                var overdueType = row.overdueType.split(",");
                                $.each(overdueType, function (i, item) {
                                    overdueTypes += '<a href="javascript:;"   class="label label-blue" >' + item + '</a>';
                                });
                            }
                        }
                        return overdueTypes;
                    }
                },
                {
                    "title": "地区",
                    "orderable": false,
                    "render": function (data, type, row, meta) {
                        areaProvince = !checkIsEmpty(row.areaProvince) ? row.areaProvince : "";
                        area = !checkIsEmpty(row.certificateArea) ? "/" + row.certificateArea : "";
                        return areaProvince + area;
                    }

                },
                {
                    "title": "适用范围",
                    "data": "applicationScope",
                    "orderable": false
                },
                {
                    "title": "创建时间",
                    "data": "createTime",
                    "orderable": false,
                    "width": "120"
                },
                {
                    "title": "是否买社保",
                    "orderable": false,
                    "width": "120",
                    "render": function (data, type, row, meta) {
                        if (row.socialSecurity == '0') {
                            return "是";
                        } else if (row.socialSecurity == '1') {
                            return "否";
                        } else {
                            return "";
                        }
                    }
                },
                {
                    "title": "适用范围",
                    "data": "socialSecurityAreaChange",
                    "orderable": false,
                    "width": "120"
                },
                {
                    "title": "收证类型",
                    "orderable": false,
                    "width": "120",
                    "render": function (data, type, row, meta) {
                        if (row.receiptType == '0') {
                            return "渠道收证";
                        } else if (row.receiptType == '1') {
                            return "人才收证";
                        } else {
                            return "";
                        }
                    }
                },
                {
                    "title": "人才付款方式",
                    "orderable": false,
                    "width": "120",
                    "render": function (data, type, row, meta) {
                        if (row.talentPaymentMethod == '0') {
                            return "签付";
                        } else if (row.talentPaymentMethod == '1') {
                            return "使用后付款";
                        } else {
                            return "";
                        }
                    }
                },
                {
                    "title": "最新入库时间",
                    "data": "lastWarehousingTime",
                    "orderable": false,
                    "width": "120"
                },
                {
                    "title": "配证生产单",
                    "data": "assignmentCertificateProductionList",
                    "orderable": false,
                    "width": "120",
                    "render": function (data, type, row, meta) {
                        return fmtMoney(data);
                    }
                },
                // {
                //     "title": "企业合同剩余时间",
                //     "data": "enterpriseContractSurplusTime",
                //     "orderable": true,
                //     "width": "120",
                //     "render": function (data, type, row, meta) {
                //         return fmtMoney(data);
                //     }
                // },
                // {
                //     "title": "人才合同剩余时间",
                //     "data": "talentsContractSurplusTime",
                //     "orderable": true,
                //     "width": "120",
                //     "render": function (data, type, row, meta) {
                //         return fmtMoney(data);
                //     }
                // },
                // {
                //     "title": "证书过期剩余时间",
                //     "data": "certificateExpiryTime",
                //     "orderable": true,
                //     "width": "120",
                // },
                {
                    "title": "操作",
                    "orderable": false,
                    "data": {},
                    "sClass": "text-center",
                    "render": function (data, type, row, meta) {
                        var hasOperation = $("[name='hasOperation']").val();
                        if(checkIsEmpty(hasOperation)) {
                            return "-";
                        }
                        var applyMoney = '<d:hasUrlAuth authCode="ZZSC_ZS_FYSQ"><a class="iboss-link" href="javascript:void(0)" onclick="applyMoneyByCertificate(\'' + row.id + '\')">费用申请</a></d:hasUrlAuth>';
                        var operation = '<d:hasUrlAuth authCode="ZZSC_ZS_BJ"><a class="iboss-link" href="javascript:void(0)" onclick="editCertificate(\'' + row.id + '\')">编辑</a></d:hasUrlAuth>';
                        operation += '<d:hasUrlAuth authCode="ZZSC_ZS_BJ"><a class="iboss-link" href="javascript:void(0)" onclick="talentRenewal(\'' + row.id + '\')">人才续签</a></d:hasUrlAuth>';
                        var inOrOut = !checkIsEmpty(row.libraryStatus) && row.libraryStatus == '在库' ? '<d:hasUrlAuth authCode="ZZSC_ZS_CK"><a class="iboss-link" href="javascript:void(0)" onclick="getOut(\'' + row.id + '\')">出库</a></d:hasUrlAuth>' : '<d:hasUrlAuth authCode="ZZSC_ZS_RK"><a class="iboss-link" href="javascript:void(0)" onclick="getIn(\'' + row.id + '\')">入库</a></d:hasUrlAuth>';
                        return operation + inOrOut + applyMoney;
                    }
                }
            ],
        });

        // 加载事业部
        syb('[name="signOrgId"]');

        loadCertificateType('190px', '#certificateType1', '${generalType}', 0);

        //异步加载
        Plug.plug_ins(
            "get",
            "${cmsBaseUrl}/api/cms/tree_book/v1/get_tree_book_list.do?code=2147483647&type=2&level=1",
            "#certificateArea",
            '请选择地区',
            function () {
            },
            true, '2147483647'
        );
        //异步加载
        Plug.plug_ins(
            "get",
            "${cmsBaseUrl}/api/cms/tree_book/v1/get_tree_book_list.do?code=2147483647&type=2&level=1",
            "#socialSecurityArea",
            '请选择地区',
            function () {
            },
            true, '2147483647'
        );

    });

</script>
</body>
</html>